﻿@using EC.Entity.Enum;
@{
    Layout = "~/Views/Shared/_Dialog.cshtml";
}
@model EC.Entity.Response.Token.TokenResponse
<section class="container-fluid" style="background-color: white;">
    <form class="form-horizontal m15_t" id="form">
        <div class="tab-content">
            <input type="hidden" id="customerId" name="customerId" value="@(Model.MerchantId)">
            <div class="tab-pane fade in active" id="home">
                <div class="form-group">
                    <label class="wd100 control-label"><span class="WdateFmtErr">*</span>AppId：</label>
                    <div class="wd275 m15_l">
                        <input class="form-control" type="text" name="appId" maxlength="11" value="@(Model.AppId)" autocomplete="off" placeholder="AppId由11位数字组成">
                    </div>
                </div>
                <div class="form-group">
                    <label class="wd100 control-label"><span class="WdateFmtErr">*</span>AppSecret：</label>
                    <div class="wd275 m15_l">
                        <input class="form-control" type="text" name="appSecret" maxlength="32" value="@(Model.AppSecret)" autocomplete="off" placeholder="AppSecret由32位字母或数字组成">
                    </div>
                </div>
                <div class="form-group">
                    <label class="wd100 control-label"><span class="WdateFmtErr">*</span>状态：</label>
                    <div class="wd275 m15_l">
                        <label class="m10_r">
                            <input type="radio" name="status" value="@((int)TokenStatus.启用)" @(Model.Status.Equals((int)TokenStatus.启用) ? "checked" : "")> 启用
                        </label>
                        <label>
                            <input type="radio" name="status" value="@((int)TokenStatus.禁用)" @(Model.Status.Equals((int)TokenStatus.禁用) ? "checked" : "")> 禁用
                        </label>
                    </div>
                </div>
            </div>
        </div>
    </form>
</section>
@section footerScript{
    <script type="text/javascript">

        function save() {

            var cover = FlashPay.UI.Mask({
                obj: $("body"),
                opacity: 0.5
            });

            var data = $("#form").serializeJSON();
            //状态
            //data.status = $("input[name='status'][checked]").val();

            FlashPay.Util.Ajax({
                type: "POST",
                url: "/Customer/SaveToken",
                data: data,
                success: function (res) {
                    if (res.success) {
                        cover.Remove();
                        FlashPay.UI.DialogOpener().Tip_success("操作成功！");
                        FlashPay.UI.DialogOpener().doSearch();
                        FlashPay.UI.CloseDialog();
                    } else {
                        cover.Remove();
                        FlashPay.UI.Tip_short_warning("操作失败！" + res.message);
                    }
                },
                error: function (json) {
                    cover.Remove();
                    FlashPay.UI.Tip_warning("操作失败！请查看网络，请重试。");
                }
            });

        }
    </script>
}